/* Setup blank page controller */
(function () {
    'use strict';
    angular.module('module.index')
        .controller('IndexController', IndexController);

    IndexController.$inject = ['$rootScope', '$scope','$uibModal'];

    function IndexController($rootScope, $scope,$uibModal) {
        var vm = this;
        vm.reward=reward;
        vm.preMenuFunction=preMenuFunction;
        vm.preGenerateCertificateNo = preGenerateCertificateNo;

        activate();

        return vm;

        function preMenuFunction(){
            var modalInstancere = $uibModal.open({
                animation: true,
                ariaLabelledBy: 'modal-title',
                ariaDescribedBy: 'modal-body',
                templateUrl: 'menuFunction.html',
                controller: 'MenuFunctionController',
                controllerAs: 'menuFunction',
                size: 'lg'
            });
            modalInstancere.result.then(function () {

            }, function () {

            });
        }

        function reward(){
            var modalInstance = $uibModal.open({
                animation: true,
                ariaLabelledBy: 'modal-title',
                ariaDescribedBy: 'modal-body',
                templateUrl: 'certificate.html',
                controller: 'CertificateController',
                controllerAs: 'certificate',
                size: 'md'
            });
            modalInstance.result.then(function () {
                //doSomething
            }, function () {
                //doSomething
            });
        }

        function preGenerateCertificateNo() {
            var modalInstance = $uibModal.open({
                animation: true,
                ariaLabelledBy: 'modal-title',
                ariaDescribedBy: 'modal-body',
                templateUrl: 'certificateGenerate.html',
                controller: 'CertificateGenerateController',
                controllerAs: 'certificateGenerate',
                size: 'md'
            });
            modalInstance.result.then(function (certificateNoGenerated) {
                vm.certificateNo = certificateNoGenerated;
                //doSomething
            }, function () {
                //doSomething
            });
        }

        function activate(){
            $scope.$on('$viewContentLoaded', function() {
                App.initAjax(); // initialize core components
            });

            // set sidebar closed and body solid layout mode
            $rootScope.settings.layout.pageContentWhite = true;
            $rootScope.settings.layout.pageBodySolid = false;
            $rootScope.settings.layout.pageSidebarClosed = false;

            $rootScope.settings.layout.pageLogin = false;
        }
    }
})();
